<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="icon" href="https://static.nowcoder.com/images/logo_87_87.png"/>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
          crossorigin="anonymous">
    <link rel="stylesheet" th:href="@{/css/global.css}"/>
    <title>牛客网-首页</title>
</head>
<body>
<div class="nk-container">
    <!-- 头部 -->
    <header th:replace="~{/site/common/layout::header}"></header>

    <!-- 内容 -->
    <div class="main">
        <div class="container">
            <div class="position-relative">
                <!-- 筛选条件 -->
                <ul class="nav nav-tabs mb-3">
                    <li class="nav-item">
                        <a class="nav-link active" href="#">最新</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#">最热</a>
                    </li>
                </ul>
                <button type="button" class="btn btn-primary btn-sm position-absolute rt-0" data-toggle="modal"
                        data-target="#publishModal">我要发布
                </button>
            </div>
            <!-- 弹出框 -->
            <div class="modal fade" id="publishModal" tabindex="-1" role="dialog" aria-labelledby="publishModalLabel"
                 aria-hidden="true">
                <div class="modal-dialog modal-lg" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title" id="publishModalLabel">新帖发布</h5>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span aria-hidden="true">&times;</span>
                            </button>
                        </div>
                        <div class="modal-body">
                            <form>
                                <div class="form-group">
                                    <label for="recipient-name" class="col-form-label">标题：</label>
                                    <input type="text" class="form-control" id="recipient-name">
                                </div>
                                <div class="form-group">
                                    <label for="message-text" class="col-form-label">正文：</label>
                                    <textarea class="form-control" id="message-text" rows="15"></textarea>
                                </div>
                            </form>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
                            <button type="button" class="btn btn-primary" id="publishBtn">发布</button>
                        </div>
                    </div>
                </div>
            </div>
            <!-- 提示框 -->
            <div class="modal fade" id="hintModal" tabindex="-1" role="dialog" aria-labelledby="hintModalLabel"
                 aria-hidden="true">
                <div class="modal-dialog modal-lg" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title" id="hintModalLabel">提示</h5>
                        </div>
                        <div class="modal-body" id="hintBody">
                            发布完毕!
                        </div>
                    </div>
                </div>
            </div>

            <!-- 帖子列表 -->
            <ul class="list-unstyled" th:unless="${#lists.isEmpty(posts)}">
                <li class="media pb-3 pt-3 mb-3 border-bottom" th:each="post : ${posts}">
                    <a href="site/profile.html">
                        <img th:src="${post.headerUrl}" class="mr-4 rounded-circle" alt="用户头像"
                             style="width:50px;height:50px;">
                    </a>
                    <div class="media-body">
                        <h6 class="mt-0 mb-3">
                            <a href="site/discuss-detail.html" th:text="${post.title}">备战春招，面试刷题跟他复习，一个月全搞定！</a>
                            <span class="badge badge-secondary bg-primary" th:if="${post.type==1}">置顶</span>
                            <span class="badge badge-secondary bg-danger" th:if="${post.status==1}">精华</span>
                        </h6>
                        <div class="text-muted font-size-12">
                            <u class="mr-3" th:text="${post.username}">寒江雪</u> 发布于 <b
                                th:text="${#dates.format(post.createTime,'yyyy-MM-dd HH:mm:ss')}">2019-04-15
                            15:32:18</b>
                            <ul class="d-inline float-right">
                                <li class="d-inline ml-2">赞 0</li>
                                <li class="d-inline ml-2">|</li>
                                <li class="d-inline ml-2">回帖 <span th:text="${post.commentCount}">7</span></li>
                            </ul>
                        </div>
                    </div>
                </li>
            </ul>
            <!-- 分页 -->
            <nav class="mt-5">
                <ul class="pagination justify-content-center">
                    <li class="page-item"><a class="page-link" th:href="@{${page.path}(current=1)}">首页</a></li>
                    <li th:class="|page-item ${page.hasPrev==false?'disabled':''}|">
                        <a class="page-link" th:href="@{${page.path}(current=${page.pageNum}-1)}">上一页</a></li>
                    <li th:class="|page-item ${page.pageNum==num?'active':''}|" th:each="num : ${page.pageSequence}">
                        <a class="page-link" th:href="@{${page.path}(current=${num})}" th:text="${num}">1</a>
                    </li>
                    <li th:class="|page-item ${page.hasNext==false?'disabled':''}|">
                        <a class="page-link" th:href="@{${page.path}(current=${page.pageNum}+1)}">下一页</a></li>
                    <li class="page-item"><a class="page-link"
                                             th:href="@{${page.path}(current=${page.totalPage})}">末页</a>
                    </li>
                </ul>
            </nav>
        </div>
    </div>

    <!-- 尾部 -->
    <footer th:replace="~{/site/common/layout::footer}"></footer>
</div>

<script src="https://code.jquery.com/jquery-3.3.1.min.js" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
        crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" crossorigin="anonymous"></script>
<script th:src="@{/js/global.js}"></script>
<script th:src="@{/js/index.js}"></script>
</body>
</html>
